<?php

 class NLogger {

  private static $_instances;

  private function __construct($file) {
	$this->file=$file;
  }

  static function getInstance($file) {
    if (!isset(self::$_instances[$file])) {
      $c = __CLASS__;
      self::$_instances[$file] = new $c($file);
    }
    return self::$_instances[$file];
  }

  // Prevent users to clone the instance
  public function __clone() {
    throw new Exception('Cannot clone the logger object.');
  }
   
  public function log($message = '') {
    $file = fopen($this->file, 'a+');
    fwrite($file, $message."\r\n");
    fclose($file);
  }
  function startTime($name = 'application')
    {
      $t=explode(' ', microtime());
        $this->logstart[$name] = $t[0]+$t[1];
    }

    /**
     * stop a timer
     *
     * @param   string  $name   name of the timer
     */
    function stopTime($name = 'application')
    {
  	$t=explode(' ', microtime());
        $this->logend[$name] = $t[0]+$t[1];    }
} 
?>